﻿using System.Collections.Generic;

namespace BlogEngine.Gallery.Models
{
    public enum PackageType
    {
        Extension, Theme, Widget
    }

    public class PackageExtra
    {
        public PackageType PkgType { get; set; }
        public string Id { get; set; }
        public int DownloadCount { get; set; }
        public float Rating
        {
            get
            {
                if (Reviews == null || Reviews.Count == 0) return 0;

                float totalVoters = 0;
                float totalPoints = 0;

                for (int i = 0; i < Reviews.Count; i++)
                {
                    totalVoters++; //+= Reviews[i].Rating;
                    totalPoints += Reviews[i].Rating; // += totalVoters * (i + 1);
                }
                return totalPoints / totalVoters;
            }
        }
        public List<Review> Reviews { get; set; }
    }
}